package com.dyw.spzx.manager.controller;

import com.dyw.spzx.manager.service.SysRoleMenuService;
import com.dyw.spzx.model.dto.system.AssginMenuDto;
import com.dyw.spzx.model.vo.common.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Tag(name = "分配菜单")
@RestController
@RequestMapping("/admin/system/sysRoleMenu")
public class SysRoleMenuController {
    @Autowired
    private SysRoleMenuService sysRoleMenuService;


    @Operation(summary = "回显当前角色拥有的菜单")
    @GetMapping("/findSysRoleMenuByRoleId/{roleId}")
    public Result<Map<String,Object>> findSysRoleMenuByRoleId(@PathVariable("roleId") Long roleId){
        Map<String,Object> sysRoleMenuList = sysRoleMenuService.findSysRoleMenuByRoleId(roleId);
        return Result.ok(sysRoleMenuList);
    }

    @Operation(summary = "保存角色分配的菜单")
    @PostMapping("/doAssign")
    public Result doAssign(@RequestBody AssginMenuDto assginMenuDto){

        sysRoleMenuService.doAssign(assginMenuDto);

        return Result.ok(null);
    }






}
